package com.key.service.impl;

import com.key.common.R;
import com.key.mapper.AdminMapper;
import com.key.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * @Author: li
 * @CreateTime: 2023-02-21  17:50
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    AdminMapper adminMapper;

    @Override

    public R showAllApprovalNumber() {

        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllNoApprovalNumber();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }


        return r;
    }

    @Override
    public R showAllSignNumber() {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllAllSignNumber();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }


        return r;
    }

    @Override
    public R showMaintenanceTimeExpireNumber(String expirationTime) {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectMaintenanceTimeExpireNumber(expirationTime);
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }


        return r;
    }

    @Override
    public R showAllApplicationAssetsNumber() {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllApplicationAssetsNumber();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;
    }

    @Override
    public R showAllocationAssetsNumber() {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllocationAssetsNumber();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;

    }

    @Override
    public R showAllSignAssetsState() {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllSignAssetsState();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;

    }

    @Override
    public R showAllStateNumber() {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllAssetsStateNumber();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;

    }

    @Override
    public R showAllAssetsCompanyNumber() {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllAssetsCompanyNumber();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;
    }

    @Override
    public R showAllAssetsDeptNumber() {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllAssetsDeptNumber();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;
    }

    @Override
    public R showAllAssetsTypeNumber() {
        R r = new R();
        try {
            List<Map<String, Object>> mapList = adminMapper.selectAllAssetsTypeNumber();
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;
    }
}
